import java.math.BigDecimal;


/****
 * Token
 * 
 * @author Nizar Oukhchi
 * 
 */
public class Token {

	private Type type;
	private String name;
	private BigDecimal num;

	public enum Type{
		PLUS, // +
		MINUS, // -
		TIMES, // *
		DIV,// /
		OPENPAR,// (
		CLOSEPAR,// )
		SEMICOLON,// ;
		BECOMES,// =
		ID,// identificator
		NUM,// number 
		UNKNOWN,
		EOS;// end of stream	
	}

	public Token(Type type, String name, BigDecimal num) {
		this.type = type;
		this.name = name;
		this.num = num;
	}

	public Token(Type type) {
		this(type, null, null);
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public BigDecimal getNum() {
		return num;
	}

	public void setNum(BigDecimal num) {
		this.num = num;
	}

	public void setType(Type type) {
		this.type = type;
	}

	public Type getType() {
		return type;
	}

	public static Token ident(String name) {
		return new Token(Type.ID, name, null);
	}

	public static Token number(String num) {
		return new Token(Type.NUM, null, new BigDecimal(num));
	}

	public static Token simple(Type type) {
		return new Token(type, null, null);
	}
}

